package com.example.yyy

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.Gravity
import android.widget.LinearLayout
import kotlinx.android.synthetic.main.activity_linear.*
import org.jetbrains.anko.dip

class LinearActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_linear)
        linear_ll_margin.orientation = LinearLayout.HORIZONTAL
        linear_ll_margin.gravity = Gravity.CENTER
        btn_linear_hmargin.setOnClickListener {
            var layoutParams = linear_ll_margin.layoutParams as LinearLayout.LayoutParams
            layoutParams.setMargins(0,dip(50),0,dip(50))
        }
        btn_linear_vmargin.setOnClickListener {
            var layoutParams = linear_ll_margin.layoutParams as LinearLayout.LayoutParams
            layoutParams.setMargins(dip(50),0,dip(50),0)
        }
        btn_linear_hpadding.setOnClickListener {
            linear_ll_margin.setPadding(0,dip(50),0,dip(50))
        }
        btn_linear_vpadding.setOnClickListener {
            linear_ll_margin.setPadding(dip(50),0,dip(50),0)
        }
    }
}